package ac.github.os.internal.core.action.player

import ac.github.os.internal.core.action.IEntityAction
import ac.github.os.internal.core.config.StringConfig
import ac.github.os.internal.core.config.get
import ac.github.os.internal.session.Cache
import ac.github.os.internal.session.Session
import taboolib.common.platform.Awake
import taboolib.common.platform.function.adaptPlayer

@Awake
class ActionBarAction : IEntityAction {
    override fun onExecute(session: Session, cache: Cache, config: StringConfig) {
        config.get<String>("val", single = true)?.let { string ->
            cache.filterIsPlayers().forEach {
                adaptPlayer(it).sendActionBar(string)
            }
        }
    }

    override val namespace: String
        get() = "player:actionbar"
}